include Makefile.gtest
CXX=g++
CXXFLAGS= -std=c++11

Target=main
LTarget = libMarsRover.a

ALLSRC = $(patsubst %.cpp,%,$(wildcard *.cpp))

TestSrc = $(filter Test%,$(ALLSRC))

Src = $(filter-out Test%,$(ALLSRC))


LOBJ = $(addsuffix .o,$(Src))
TOBJ = $(addsuffix .o,$(TestSrc))

INC_PATH = 
LIB_PATH = \
	    $(GTEST_PATH) \
	   ./\

		
LIB = \
	$(GTEST_LIB) \
	MarsRover \

STATIC_LIB = $(addprefix -L,$(LIB_PATH)) $(addprefix -l,$(LIB)) 



all: 
	echo "please select lib or run"


$(Target):$(TOBJ)
	$(CXX) $(CXXFLAGS) $(STATIC_LIB) $(TOBJ) -o $@

lib:$(LTarget)

$(LTarget):$(LOBJ)
	ar -rc $@ $(LOBJ)

clean:
	rm $(LOBJ) $(TOBJ) $(Target)  $(LTarget)
run:$(Target)
	./$(Target)

$(OBJ):%.o:%.cpp
	echo "gen $(OBJ)"
	$(CXX) $(CXXFLAGS) $(INC_PATH) -c $<


 
